package com.aaa.qy127.service.impl;

import com.aaa.qy127.dao.UserDao;
import com.aaa.qy127.entity.User;
import com.aaa.qy127.service.UserService;
import com.aaa.qy127.util.Result;
import org.springframework.stereotype.Repository;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

@Service("UserServiceImpl")
public class UserServiceImpl implements UserService {
    @Resource(name = "UserDaoImpl")
    private UserDao userDao;

    /**
     * 获取用户信息
     * @param user
     * @return
     */
    @Override
    public Result getUser(User user) {
        List<Map<String, Object>> list = userDao.getUser(user);
        int userCount = userDao.getUserCount(user);
        Result result = new Result(userCount, list);
        return result;
    }
    /**
     * 获取用户禁用信息
     * @param user
     * @return
     */
    @Override
    public Result getcause(User user) {
        List<Map<String, Object>> getcause = userDao.getcause(user);
        Result result = new Result(getcause.size(), getcause);
        return result;
    }
    /**
     * 修改禁用状态
     * @param user
     * @return
     */
    @Override
    public String statusno(User user) {
        int statusno = userDao.statusno(user);
        if (statusno>0){
            int addcause = userDao.addcause(user);
            if (addcause>0){
                return "1001";
            }else {
                return "1002";
            }
        }else {
            return "1002";
        }
    }
    /**
     * 修改使用状态
     * @param user
     * @return
     */
    @Override
    public String statusyes(User user) {
        int statusyes = userDao.statusyes(user);
        if (statusyes>0){
            return "1001";
        }else {
            return "1002";
        }
    }
}
